<?php
class Journal_Block_Searcher extends Epic_View_Block {	
	public function getResutls () {
		$title = $_GET['titleSearch'];
		$query = "
			SELECT p.*,j.`name` FROM pager as p 
			LEFT JOIN journal as j ON (p.id_journal=j.id_journal)
			LEFT JOIN topic_pager as tp ON (tp.id_pager=p.id_pager) 
			LEFT JOIN topics as t ON (t.id_topic=tp.id_topic)
			LEFT JOIN author_pager as ap ON (ap.id_pager=p.id_pager)
			WHERE p.`name` LIKE '%".$title."%' OR j.`name` LIKE '%".$title."%' OR t.`name` LIKE '%".$title."%' OR ap.name_author LIKE '%".$title."%'
			GROUP BY id_pager
		";
		return Epic::getAdapter()->query($query)
  				  			 ->fetchAll();
	}	
	public function getTopics () {
		return Epic::getModel('journal/Topic')->getCollection()
			->load();
	}
}